pub mod pretty_json;
pub mod base64;
pub mod date;
pub mod json;
pub mod jwt;
pub mod write_excel;
pub mod struct_;
pub mod base64_utils;
pub mod to_owned;

pub mod pointer;
pub mod error;
pub mod fib;
pub mod link_list;
pub mod sqlite;

/// 可变借用与不可变借用
//参数为i32类型不可变引用
pub fn show(x: &i32){
    println!("{}", x);
}

#[test]
pub fn test1(){
    let mut x = 343;
    let px = &mut x;
    show(px);
    *px = 34;
    eprintln!("{}", x);
}
#[test]
pub fn test2(){
    let mut x = 343;

    //可变借用,以后不能直接访问x
    let mutpx = &mut x;
    *mutpx = 34;
    //println!("{}", x); //程序恐慌
    println!("{}", *mutpx);

}


#[test]
pub fn test3(){
    let mut x = 343;
    //可变借用出了作用域，x可以再次访问
    {
        let mutpx = &mut x;
        *mutpx = 34;
    }
    println!("{}", x); //34 没问题
}

struct User{
    name: String
}
fn createUser() -> User{
    User{
        name: String::new(),
    }
}
#[test]
pub fn test4(){
    let mut u: User = createUser();
    u.name = String::from("李四");
    println!("{}", u.name);
}